package com.imm.da.main.weather.api

import android.content.Context
import com.qweather.sdk.bean.base.Code
import com.qweather.sdk.bean.base.Lang
import com.qweather.sdk.bean.base.Type
import com.qweather.sdk.bean.geo.GeoPoiBean
import com.qweather.sdk.view.QWeather

/**
 * <p>------------------------------------------------------
 * <p> Copyright (C) 2021 zhangmz, All rights reserved.
 * <p> If there is technical discussion, you can contact zhangmz90@foxmail.com
 * <p>------------------------------------------------------
 * <p> des
 * <p>
 *
 * @author Created by zhangmz
 * @date on 2021/12/1
 */
class HePoiService {

    /**
     * POI（景点、火车站、飞机场、港口等）信息查询提供该兴趣点的基本信息查询
     * @param location 地区名称, 例如 location=北京 或 location=116.41,39.92
     * @param type scenic 景点/CSTA 潮流站点/TSTA 潮汐站点
     */
    fun poi(context : Context, location : String, type : Type){
        QWeather.getGeoPoiLookup(context, location, type, object : QWeather.OnResultGeoPoiListener {
            override fun onSuccess(bean: GeoPoiBean?) {
                if (Code.OK == bean?.code){
                    return
                }
            }
            override fun onError(t: Throwable?) {
            }
        })
    }

    /**
     * POI范围搜索
     * @param radius 范围，1-50之间，单位:公里，默认5公里
     */
    fun poiRange(context : Context, location : String, radius : Int = 10, type : Type){
        QWeather.getGeoPoiRange(context, location, radius, type, Lang.ZH_HANS, object : QWeather.OnResultGeoPoiListener {
            override fun onSuccess(bean: GeoPoiBean?) {
                if (Code.OK == bean?.code){

                    return
                }
            }
            override fun onError(t: Throwable?) {
            }
        })
    }

}